package leecode

import "strconv"

func crackNumber(ciphertext int) int {
	str := strconv.Itoa(ciphertext)
	if len(str) <= 1 {
		return 1
	}
	dp := make([]int, len(str)) //dp数组存放加密到第i位有几种加密方法
	//初始化dp
	dp[0] = 1
	if str[:2] >= "10" && str[:2] <= "25" {
		dp[1] = 2
	} else {
		dp[1] = 1
	}
	for i := 2; i < len(str); i++ {
		temp := str[i-1 : i+1]
		if temp >= "10" && temp <= "25" {
			dp[i] = dp[i-1] + dp[i-2]
		} else {
			dp[i] = dp[i-1]
		}
	}
	return dp[len(dp)-1]
}
